import Vue from 'vue'
import Router from 'vue-router'
import routesData from '@/common/js/router.js'
import routes from './routes.js'
import iView from 'iview'
import Home from '@/view/home'
import surveryDetails from '@/view/survey/surveyContent/surveryDetails'

// console.log(routes)
// console.log(routesData)

// let newArray = []

// routesData.forEach((item,index) => {
// 	// 二级菜单数组
// 	let classBList = []

// 	item.classA.forEach((_item,_index) => {
// 		let classBRoute = {
// 			// children: [],
// 			component: surveryDetails,
// 			// component: () => require(`@/view/${item.classAName}/${item.classAName}`),
// 			path: `/${item.classAName}/${_item.classBName}`,
// 			redirect: `${item.classB[_item.classBName][0].path}`,
// 		}
// 		classBList.push(classBRoute)
// 	})



// 	let classARoute = {
// 		children: classBList,
// 		component: Home,
// 		path: `/${item.classAName}`,
// 		redirect: `${item.classA[0].path}`,
// 	}

// 	newArray.push(classARoute)
// })

// console.log(newArray)

Vue.use(Router)

const router = new Router({
  routes,
  mode: 'hash'
})

router.beforeEach((to, from, next) => {
  iView.LoadingBar.start();
  next();
});

router.afterEach(to => {
  iView.LoadingBar.finish()
  // window.scrollTo(0, 0)
})

export default router
